import requests


class IHRMManageDepartApi:

    # 封装新增部门的方法
    @classmethod
    def add_department(cls, token, body):
        url = "http://ihrm2-test.itheima.net/api/company/department"
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=url, headers=header, json=body)
        return resp

    # 封装查询部门的方法
    @classmethod
    def query_department(cls, depart_id, token):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + depart_id
        header = {"Authorization": token}
        resp = requests.get(url=url, headers=header)
        return resp

    # 封装修改部门的方法
    @classmethod
    def modify_department(cls, depart_id, token, body):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + depart_id
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=url, headers=header, json=body)
        return resp

    # 封装删除部门的方法
    @classmethod
    def del_department(cls, depart_id, token):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + depart_id
        header = {"Authorization": token}
        resp = requests.delete(url=url, headers=header)
        return resp
